<template>
	<view class="home">
		<custom-navbar title="更新简历" :show-back="true" @back="handleBack" />

		<view class="content " :style="{ paddingTop: navBarHeight + 'px' }">
			<view class="p30">
				<view class="item p4030 fcsb mb20" @click="handlepersonal">
					<view>
						<view class="f245c3 mb15">个人信息</view>
						<view class="f30bc0 fc">
							<view v-if="resumeData.basic_information == true" class="c9">已填写</view>
							<view v-else>未填写</view>
						</view>
					</view>
					<view class="fc">
						<view class="f24c6">填写</view>
						<image class="wh24 ml5" src="/static/images/home/Frame(2).svg"></image>
					</view>
				</view>
				<view class="item p4030 fcsb mb20" @click="handleeducation">
					<view>
						<view class="f245c3 mb15">教育经历</view>
						<view class="f30bc0 fc">
							<view v-if="resumeData.educationackgrounds == true" class="c9">已填写</view>
							<view v-else>非必填，如补充更好</view>
						</view>
					</view>
					<view class="fc">
						<view class="f24c6">填写</view>
						<image class="wh24 ml5" src="/static/images/home/Frame(2).svg"></image>
					</view>
				</view>
				<view class="item p4030 fcsb mb20" @click="handlework">
					<view>
						<view class="f245c3 mb15">工作经历</view>
						<view class="f30bc0 fc">
							<view v-if="resumeData.work_experiences == true" class="c9">已填写</view>
							<view v-else>非必填，如补充更好</view>
						</view>
					</view>
					<view class="fc">
						<view class="f24c6">填写</view>
						<image class="wh24 ml5" src="/static/images/home/Frame(2).svg"></image>
					</view>
				</view>
				<view class="item p4030 fcsb" @click="handleintroduce">
					<view>
						<view class="f245c3 mb15">自我介绍</view>
						<view class="f30bc0 fc">
							<view v-if="resumeData.self_introduction  == true" class="c9">已填写</view>
							<view v-else>非必填，如补充更好</view>
						</view>
					</view>
					<view class="fc">
						<view class="f24c6">填写</view>
						<image class="wh24 ml5" src="/static/images/home/Frame(2).svg"></image>
					</view>
				</view>
			</view>
		</view>

	</view>

</template>

<script setup>
	import CustomNavbar from '@/components/custom-navbar.vue'
	import {
		ref,
		onMounted,
		computed
	} from 'vue';
	import {
		talentstatus
	} from '@/api/talents'
	// 2. 获取系统信息（同步操作放在setup最前面）
	const systemInfo = uni.getSystemInfoSync()

	// 3. 定义响应式数据
	const searchKey = ref('')
	const resumeData = ref({})

	// 4. 计算属性
	const navBarHeight = computed(() => systemInfo.statusBarHeight + 44)

	onMounted(async () => {
		await getResumeInfo()
	})

	const getResumeInfo = async () => {
		try {
			const res = await talentstatus()
			if (res.code === 200) {
				resumeData.value = res.data.data
			}
		} catch (e) {
			console.error(e)
		}
	}

	const handleBack = () => {
		uni.navigateBack()
	};
	const handlepersonal = (val) => {
		uni.navigateTo({
			url: `/pages/resume/personal`
		});
	};
	const handleeducation = (val) => {
		if (resumeData.value.educationackgrounds == true) { // 注意字段名修正
			uni.navigateTo({
				url: `/pages/resume/education`
			});
		} else {
			uni.navigateTo({
				url: `/pages/resume/AddEducation`
			});
		}
	};
	const handlework = (val) => {
		if (resumeData.value.work_experiences == true) { // 注意字段名修正
			uni.navigateTo({
				url: `/pages/resume/work`
			});
		} else {
			uni.navigateTo({
				url: `/pages/resume/AddWork`
			});
		}
	};
	// 自我介绍 
	const handleintroduce = (val) => {
		uni.navigateTo({
			url: `/pages/resume/introduce`
		});
	}
</script>

<style lang="scss" scoped>
	.home {
		width: 100%;
		min-height: 100vh;
		position: relative;

		.content {
			padding-top: var(--status-bar-height);
			padding-top: calc(var(--status-bar-height) + 70rpx);
			/* 导航栏高度 */
			display: flex;
			flex-direction: column;

			// align-items: center;
			// justify-content: center;
			.item {
				width: 100%;
				height: 160rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
			}

		}
	}
</style>